﻿<%@ Page Language="C#" EnableViewState="false"  AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="SysManage.Module.Edu.test" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css">
        .onesubject {
            border-bottom: 1px solid #e3ebeb;
            margin-bottom: 20px;
        }

        .onesubject_title {
            font-size: 16px;
            font-weight: 700;
            padding-bottom: 10px;
        }

        .onesubject_Options {
            padding-bottom: 10px;
            padding-left: 20px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div><asp:Literal runat="server" ID="litRs"></asp:Literal></div>
        <asp:Repeater runat="server" ID="rptSubject" OnItemDataBound="rptSubject_ItemDataBound">
            <ItemTemplate>
                <div class="onesubject">
                    <div class="onesubject_title">
                        <%#Eval("Subjectcontent") %>
                         <asp:HiddenField runat="server" ID="hdSubjectID" Value='<%#Eval("ID") %>' />
                    </div>
                    <div>
                        <asp:Repeater runat="server" ID="rptOptions" >
                            <ItemTemplate>
                                <div class="onesubject_Options">
                                    <input id="<%#Eval("ID") %>" name="<%#Eval("ID") %>" type="checkbox" /><label id="lable<%#Eval("ID") %>" for="<%#Eval("ID") %>"><%#  _leter[Container.ItemIndex]+"、"+ Eval("OptionsContent") %></label>
                                </div>
                             
                            </ItemTemplate>
                        </asp:Repeater>
                    </div>
                </div>
            </ItemTemplate>
        </asp:Repeater>
        <asp:HiddenField runat="server" ID="hdSubjectIDs" />
        <asp:HiddenField runat="server" ID="hdAnswer" Value="" />
        <asp:HiddenField runat="server" ID="hdSubmit" Value="" />
        <div runat="server" id="divbtnsubmit">
        <input type="button" id="btnSubmit" value="提交" />
        <div style="display:none"><asp:Button runat="server" ID="btnSubmitEx" OnClick="btnSubmitEx_Click" Text="提交" /></div>
            </div>
    </form>
</body>
</html>
<script src=".././../../../Scripts/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        if ($("#hdAnswer").val() != "")
        {
            //做题后
            var Answerstrs = new Array(); //定义一数组 
            Answerstrs = $("#hdAnswer").val().split(","); //字符分割 
            $.each(Answerstrs, function (i, n) {
                $("#lable" + n).css({ color: "red" });
            });

            var Submitstrs = new Array(); //定义一数组 
            Submitstrs = $("#hdSubmit").val().split(","); //字符分割 
            $.each(Submitstrs, function (i, n) {
                $("#" + n).attr("checked", true);
              
            });
            $("input", '.onesubject_Options').attr("disabled", true);
            return;
        }

        $("#btnSubmit").click(function () {
            var rs = check();
            if (rs)
            {
                $("#btnSubmitEx").click();
            }
            else
            {
                alert("请完成已标红的题目！");
            }
        });
        
    });
    function check() {
        var rs = true;
        $(".onesubject").each(function (i, n) {
            if ($("input:checked", $(n)).length < 1) {
                rs = false;
                $(".onesubject_title", $(n)).css({ color: "red" });//标红
            } else {
                $(".onesubject_title", $(n)).css({ color: "#000" });//标红
            }
        });
        return rs;
    }
    function dataError() {
        alert("提交失败，数据异常");
        location.href = location.href;
    }
</script>